package com.uenpay.im.ui.old.activity.login;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.uenpay.im.IMApplication;
import com.uenpay.im.R;
import com.uenpay.util.app.base.BaseActivity;

/**
 * @Author: SL
 * @Date: 2017/4/17 15:46
 * @CopyRight: http://www.qiyunxin.com
 * @Parameter: TODO
 * @Function: TODO
 */
public class UpdateDomainActivity extends BaseActivity {

    private EditText domainName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        isFullScreen = true;
        super.onCreate(savedInstanceState);
    }

    @Override
    public View bindView() {
        return null;
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_update_domain_layout;
    }

    @Override
    public void initView(View view) {
        initView();
        initListener();

        String url = IMApplication.config.getBaseApiUrl();
        if (!TextUtils.isEmpty(url) && !url.equals("http://api2.qiyunxin.com/")) {
            domainName.setText(url);
        }
    }

    protected void initView() {
        domainName = (EditText) findViewById(R.id.account_edit);
        ((TextView) findViewById(R.id.title_textview)).setText(getResources()
                .getString(R.string.update_domain));
    }

    protected void initListener() {
        findViewById(R.id.save_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = domainName.getText().toString();
                IMApplication.config.setBaseApiUrl(url);
                finish();
            }
        });
    }
}
